import config from '../config/config';
import request from '../utils/request';

let service = {};
//砍价列表
service.getBargainList = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getBargainList;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//检查商品状态
service.bargainCheck = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.bargainCheck;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//我的砍价列表
service.BargainUser = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.BargainUser;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//2.12.0买家今日热销商品
service.customerRecommend = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.customerRecommend;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}
//砍价订单详情
service.getbargainorderdetail = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getbargainorderdetail;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}
//砍价排行榜详情
service.getbargainfriendList = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getbargainfriendList;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//1分拿轮播
service.getCycleMsg = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.getCycleMsg;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    }
  });
}

//点击给好友砍价
service.bargainFriend = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.bargainFriend;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    }
  });
}
// 支付砍价订单
service.pay_bargain_order = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.pay_bargain_order;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    },
    fail: res=> {
      cb(res)
    }
  });
}
// 发起砍价订单
service.init_bargain_order = (param, cb) => {
  param = param || {};
  let requestUrl = config.api.init_bargain_order;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'POST',
    success: res => {
      cb(res);
    },
    fail: res => {
      cb(res)
    }
  });
}






module.exports = service;